package fr.umlv.galcon.ship.type;

import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;

import fr.umlv.galcon.ship.Squadron;

public class StrongShip extends TriangularShip {

    private final Rectangle2D shape;

    public StrongShip(int x, int y, int width, Squadron squadron) {
	super(x, y, width, squadron.getOriginPlanet().getShipProperties(), squadron);
	this.shape = new Rectangle2D.Double(x, y, width, width);
    }

    @Override
    public void draw(Graphics2D graphics) {
	double currentX = super.getCenter().getX();
	double currentY = super.getCenter().getY();

	// If there's a move
	if (currentX != super.getSquadron().getDestinationPlanet().getCenter().getX()
		|| currentY != super.getSquadron().getDestinationPlanet().getCenter().getY()) {
	    super.getShipMovement().moveTo();
	}

	// blink the ship if selected
	super.getShipSelectorManager().blinkSelection(graphics);

	// Change the orientation of the Ship
	super.orientationShip();

	graphics.drawPolygon(super.getXVertices(), super.getYVertices(), 3);
	graphics.fillPolygon(super.getXVertices(), super.getYVertices(), 3);

	// Delete the squadron if arrived to its destination
	super.getShipMovement().impactDestination(graphics);

    }

    @Override
    public Shape getShape() {
	return shape;
    }

}
